Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
최단거리 문제 풀이 시 주의 사항
❗idea
💡코드 작성 전에
지름길
이번주 알고리즘 분류를 보고 무조건 다익스트라로 풀어야 겠다고 생각하고 문제를 접근한 것이 화근이었습니다.
처음에는 우선순위 큐에 <시작점, 끝점, 가중치>가 있는 노드를 넣고, 지름길로 얻을 수 있는 이득의 비율이 가장 큰 순서로 정렬하는 방식을 사용했습니다.
하지만, 이 문제는 단순히 가장 지름길을 먼저 선택한다고 해서 풀리는 문제가 아니라는 것을 깨달았습니다. (10%씩 줄어드는 지름길 두 개와 15% 줄어드는 지름길이 있다고 가정할 때, 10%씩 줄어드는 지름길 두 개를 선택하는 것이 훨씬 이득)
이후 알고리즘에 집중하지 않고 문제를 찬찬히 읽어보았습니다.
이와 같은 조건에서 dp로 풀 수 있겠다는 생각을 하게 되었고, 이대로 풀게 되었습니다.
숨바꼭질 3
서강그라운드
택배